<template>
	<view>
		<u-swipe-action :autoClose="true">
			<view class="" v-for="(item,index) in cartList" :key="item.goods_id">
				<u-swipe-action-item :options="options2" :name=item.goods_id :disabled='action' @click="deleted">
					<view class="goods-item ">
						<view class="goods-item-left">
							<u-checkbox-group shape="circle" activeColor="#C00000" v-if="showCheckbox">
								<u-checkbox name="" v-if="showCheckbox" :checked="item.goods_state"
									@change="checkedBox(item)"></u-checkbox>
							</u-checkbox-group>
							<image mode="aspectFit" :src="item.goods_small_logo" @click="gotoDetail(item)"></image>
						</view>
						<view class="goods-item-right">
							<view class="text">{{item.goods_name}}</view>
							<view class="goods-info-box">
								<view class="price">￥{{item.goods_price | goods_price}}</view>
								<view class="counter" v-if="number_box">
									<u-number-box button-size="30" :integer="true" color="#000" bgColor="#f5f5f5" iconStyle="color: #000"
										:min="1" :max="10" @change="changenNum" :name="item.goods_id"
										:value="item.goods_count"></u-number-box>
								</view>
								<view class="evals" v-else @click="appraise(item)">
									<u-button text="去评价" size="normal" shape="circle" class="u-button"
										color="linear-gradient(to right,  rgb(255, 119, 1), rgb(255, 93, 0))"></u-button>
								</view>
							</view>

						</view>
					</view>
				</u-swipe-action-item>
			</view>
		</u-swipe-action>

	</view>
</template>

<script>
	import myMixins from "../../mixins/filterPrice.js"
	export default {
		name: "myCart",
		props: {
			cartList: {
				type: Array,
				default: []
			},
			action: { //是否可以平滑
				type: Boolean,
				default: false
			},
			number_box: { //是否显示计算数量
				type: Boolean,
				default: true
			},
			showCheckbox: { //是否显示Checkbox
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				options2: [{
					text: '删除',
					style: {
						backgroundColor: '#f56c6c'
					}
				}],
			};
		},
		mixins: [myMixins],
		methods: {
			deleted(e) {
				this.$emit("deleted", e)
			},
			changenNum(item) {
				this.$emit("changenNum", item)
			},
			gotoDetail(item) {
				this.$emit("gotoDetail", item)
			},
			checkedBox(item) {
				this.$emit("checkedBox", item)
			},
			appraise(item){
		
			let good = {
				goods_id:item.goods_id,
				goods_name:item.goods_name,
				goods_small_logo:item.goods_small_logo,
				goods_price:item.goods_price
			}
				uni.navigateTo({
					url:"/subCustomer/appraise/appraise?good=" + JSON.stringify(good)
				})
			}
		},
	}
</script>

<style lang="scss">
	.goods-item {
		display: flex;
		margin-left: 10rpx;
		border: 1rpx solid #f4f4f4;

		.goods-item-left {
			display: flex;
			justify-content: space-around;
			align-items: center;
			margin: 20rpx 0;


			image {
				width: 200rpx;
				height: 200rpx;
				margin-right: 10rpx;
			}
		}

		.goods-item-right {
			width: 100%;
			display: flex;
			flex-direction: column;
			justify-content: space-around;

			.evals {
				padding-right: 15px;
				.u-button{
					width: 60px;
					height: 30px;
				}
			}

			.goods-info-box {
				display: flex;
				flex-direction: row;
				justify-content: space-between;

				.counter {
					padding-right: 20rpx;
				}

				.price {
					font-size: 16px;
					color: #c00000;
				}
			}

			.text {
				padding-right: 20rpx;
				font-size: 700;
				font-size: 26rpx;
			}
		}
	}
</style>